const { ipcRenderer } = window.require('electron');

function fetch(action, params, { type, headers }) {
    return new Promise((resolve, reject) => {
        ipcRenderer.invoke('user-net-request', {
            action,
            params,
            headers,
            type
        }).then((res) => {
            console.log(res);
            resolve(res);
        });
    });
}

export function injectNet(XUE) {
    XUE.net = {
        fetch,
    };
}
